Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Graphics /
Chapter 6 - Picture Shapes / About Picture Shapes


About Hit-Testing Picture Shapes

When the user clicks the mouse, your application receives the information from the Macintosh Toolbox about where the mouse click occurred. By sending this information to the GXHitTestPicture function, you can find out which item in a picture was hit. This process is called hit-testing a picture shape.

When hit-testing a picture shape, QuickDraw GX searches through the shapes contained in the picture until it finds the shape that was hit by the hit-test point. As QuickDraw GX searches through the shapes in the picture, it

QuickDraw GX returns information about the first item that was hit and satisfies the criteria.

Since more than one shape in a picture can be hit during a single hit-test, you provide QuickDraw GX with extra selection criteria when hit-testing a picture. Specifically, you specify a depth and a level:

Figure 6-18 shows an example. The picture shape shown in this figure has two items, each of which are pictures. Each of these pictures has two items itself, making a total of four shapes that have a level of 2 in this hierarchy.

This figure shows the picture as drawn, and three sample hit-test points.

Figure 6-18 A picture shape and hit-test points

The first sample hit-test point hits only one shape: the lawn path shape. If you specified a depth of 1, QuickDraw GX would select this shape as the hit shape. The shape returned by QuickDraw GX, however, depends on what you specify for the level. If you specify 2, the lawn path shape would be returned. If you specified 1, however, the picture that contains the lawn path shape would be returned.

The second sample hit-test point hits two shapes: at depth 1, it hits the house rectangle; at depth 2, it hits the lawn shape. You determine which is the hit shape by specifying a depth of 1 or 2. You also specify whether QuickDraw GX returns the hit shape (by specifying level 2) or the picture that contains the hit shape (by specifying level 1).

The third hit-test point hits three shapes: at depth 1, it hits the house rectangle; at depth 2, it hits the walkway polygon; at depth 3, it hits the lawn shape. Again, you can determine which of these shapes is the hit shape (by specifying the depth) and whether the hit shape or the picture that contains it is returned (by specifying the level).

For programming examples of hit-testing picture shapes, see "Hit-Testing Pictures" beginning on page 6-46.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help